Skip to content

Add randomUUID() support#290

Closed
Syed-Moiz-Ali wants to merge 1 commit into
google:masterfrom
Syed-Moiz-Ali:feat/random-uuid
Closed

Add randomUUID() support#290
Syed-Moiz-Ali wants to merge 1 commit into
google:masterfrom
Syed-Moiz-Ali:feat/random-uuid

Conversation

@Syed-Moiz-Ali

Copy link
Copy Markdown
Contributor

Fixes #187

Adds
andomUUID()\ function matching the \Crypto.randomUUID()\ Web API:

  • JS backend: delegates to \window.crypto.randomUUID()\ via \dart:js_interop\
  • FFI backend: generates UUID v4 using BoringSSL \RAND_bytes\ with correct version (4) and variant (RFC 4122) bits
  • Stub backend: throws \UnimplementedError\

The public API is a top-level \String randomUUID()\ function in \package:webcrypto.

Tests verify:

  • UUID format (length, dashes, version nibble, variant nibble, hex characters)
  • Uniqueness across 100 generated UUIDs

Implements Crypto.randomUUID() from the Web Crypto specification
across all backends:

- JS backend: delegates to window.crypto.randomUUID() via dart:js_interop
- FFI backend: generates UUID v4 using BoringSSL RAND_bytes
- Stub backend: throws UnimplementedError

The public API is exposed as a top-level randomUUID() function that
returns a version 4 UUID string in the format
xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx.

Fixes google#187
@HamdaanAliQuatil

Copy link
Copy Markdown
Collaborator

this is planned for 1.1.0. putting this on hold as there will be major architectural drifts with native assets and JCA work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider adding support for randomUUID

2 participants